package com.liumuxian.exam.web.controller;

import com.liumuxian.exam.dao.SubjectAssoetedDao;
import com.liumuxian.exam.pojo.SubjectAssoeted;
import com.liumuxian.exam.service.SubjectAssoetedExamClassifyExamInfoService;
import com.liumuxian.exam.service.SubjectAssoetedService;
import entity.Result;
import entity.StatusCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
    @RequestMapping("/o")
public class SubjectAssoetedController {
    @Autowired
    private SubjectAssoetedService subjectAssoetedService;
    @Autowired
    private SubjectAssoetedExamClassifyExamInfoService subjectAssoetedExamClassifyExamInfoService;
    @GetMapping("/templateset/{tid}")
    public Result templateset(@PathVariable String tid){
        List<SubjectAssoeted> subjectAssoeted = subjectAssoetedService.findAllByTemplatesetid(tid);
        return new Result(true, StatusCode.OK,"成功",subjectAssoeted);
    }
    @PostMapping("/save")
    public Result save(@RequestBody SubjectAssoeted subjectAssoeted){
        subjectAssoetedService.save(subjectAssoeted);
        return new Result(true, StatusCode.OK,"保存成功！");
    }
    @PostMapping("/update")
    public Result update(@RequestBody SubjectAssoeted subjectAssoeted){
        subjectAssoetedService.update(subjectAssoeted);
        return new Result(true, StatusCode.OK,"修改成功！");
    }
    @DeleteMapping("/delete/{id}")
    public Result delete(@PathVariable String id){
        subjectAssoetedService.delete(id);
        return new Result(true, StatusCode.OK,"删除成功！");
    }
    @GetMapping("/list")
    public Result findAllGesTate(){
        List<SubjectAssoeted> subjectAssoetedList = subjectAssoetedService.findAllGesTate(null,null,0);
        return new Result(true, StatusCode.OK,"查询成功！",subjectAssoetedList);
    }
    @GetMapping("/{id}")
    public Result findById(@PathVariable String id){
        SubjectAssoeted subjectAssoetedList = subjectAssoetedService.findById(id);
        return new Result(true, StatusCode.OK,"查询成功！",subjectAssoetedList);
    }
    
}
